package com.koron.css2.serviceManage.mapper;

import com.koron.css2.serviceManage.bean.RoleModuleBean;
import com.koron.css2.serviceManage.bean.TWaterCompanyBean;
import com.koron.css2.serviceManage.bean.TWaterCompanyNameListBean;
import com.koron.css2.serviceManage.bean.WaterCompanyListBean;
import com.koron.css2.serviceManage.queryBean.CompanyQueryBean;
import com.koron.css2.serviceManage.queryBean.TWaterCompanyQuery;
import com.koron.css2.serviceManage.vo.ComboBoxVO;
import com.koron.css2.serviceManage.vo.CompanyVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;

@EnvSource("_default")
public interface TWaterCompanyMapper {

	/**
	 * 查询
	 */
	List<CompanyVO> select(CompanyQueryBean bean);

	/**
	 * 根据id查询
	 */
	TWaterCompanyBean selectById(String id);

	/**
	 * 根据code查询
	 */
	TWaterCompanyBean selectByCode(String code);

	/**
	 * 校验字段内容重复
	 */
	@Select("select count(*) from PUB_COMPANY where ${key} = #{val}")
	Integer check(@Param("key") String key, @Param("val") String val);

	/**
	 * 校验字段内容重复-排除当前记录
	 */
	@Select("select count(*) from PUB_COMPANY where ${key} = #{val} and company_id <> #{id}")
	Integer check2(@Param("key") String key, @Param("val") String val, @Param("id") String id);

	/**
	 * 添加水司
	 */
	Integer save(TWaterCompanyBean tWaterCompany);

	/**
	 * 修改水司
	 */
	Integer update(TWaterCompanyBean tWaterCompany);
	
	List<ComboBoxVO> selectComboBox();

	/**
	 * 根据code列表查询
	 */
	List<TWaterCompanyBean> selectTWaterCompanyByCodeList(@Param("list") List<String> list);

	List<RoleModuleBean> selectRoleModule();

	List<WaterCompanyListBean> selectTWaterCompanyList();

	/**
	 * 根据水司编号查询其管理员的loginid
	 */
	public String getManagerLoginIdByGroup(@Param("group") String group);

	/**
	 * 查询所有的水司名称和编号
	 * 
	 * @param dataSourceAccount
	 * @param targetAccount
	 * @param tableName
	 * @return
	 */
	List<TWaterCompanyNameListBean>  selectCompanyName();
	/**
	 * 获取水司编号
	 * @return
	 * @param waterCodeFilter
	 */
	public List<String>  selectCompany(String  waterCodeFilter);
	/**
	 * 根据用户水司编号获取行政区域
	 */
	public String selectCompanyByCode(String code);

	TWaterCompanyBean getSingle(TWaterCompanyQuery tWaterCompanyQuery);

	/**
	 * 根据用户水司编号获取数据库名
	 */
	public String selectDataBaseByCode(String code);
}